﻿using System;

namespace Eswat.Client.Wpf.ViewModels
{
	public class TestResultViewModel : ViewModelBase
	{
		public TestResultViewModel(TestResult testResult)
			: base()
		{
			this.Text = string.IsNullOrEmpty(testResult.TestDescription) ? "*No Description*" : testResult.TestDescription;

			if (testResult.Status == TestStatus.Succeeded) this.ImageSource = "Images/success.png";
			else if (testResult.Status == TestStatus.Error) this.ImageSource = "Images/failure.png";
			else if (testResult.Status == TestStatus.Failed) this.ImageSource = "Images/failure.png";
			else this.ImageSource = "Images/inconclusive.png";
		}

		private string _text;

		public string Text
		{
			get { return this._text; }

			private set
			{
				if (this._text != value)
				{
					this._text = value;
					this.OnPropertyChanged(() => this.Text);
				}
			}
		}

		private string _imageSource;

		public string ImageSource
		{
			get { return this._imageSource; }

			private set
			{
				if (this._imageSource != value)
				{
					this._imageSource = value;
					this.OnPropertyChanged(() => this.ImageSource);
				}
			}
		}
	}
}
